{php include wl_template('common/header');}
<div class="app-content">
	<ul class="nav nav-tabs" id="myTab">
		<li class="active"><a href="#tab_basic">签到设置</a></li>
		<li><a href="#tab_share">规则分享</a></li>
		<li><a href="#tab_adv">广告设置</a></li>
	</ul>
	<div class="app-form">
		<div class="main">
			<form action="" method="post" id="setting-form" class="form-horizontal form">
				<div class="panel panel-default">
					<div class="panel-body">
						<div class="tab-content">
							<div class="tab-pane active" id="tab_basic">
								<div class="panel-heading">签到设置</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">开启签到系统</label>
									<div class="col-sm-9">
										<label class="radio-inline">
											<input type="radio" name="set[signstatus]" value="1" {if intval($settings['signstatus']) == 1}checked="checked"{/if}>开启
										</label>
										<label class="radio-inline">
											<input type="radio" name="set[signstatus]" value="0" {if intval($settings['signstatus']) == 0 || empty($settings['signstatus'])}checked="checked"{/if}>关闭
										</label>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">开启自动签到</label>
									<div class="col-sm-9">
										<label class="radio-inline">
											<input type="radio"  name="set[autosign]" value="1" {if intval($settings['autosign']) == 1}checked="checked"{/if}>开启
										</label>
										<label class="radio-inline">
											<input type="radio" name="set[autosign]" value="0" {if intval($settings['autosign']) == 0 || empty($settings['autosign'])}checked="checked"{/if}>关闭
										</label>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">签到周期</label>
									<div class="col-sm-9">
										<label class="radio-inline">
											<input type="radio" id="inlineRadio3" name="set[cycletype]" value="1" {if intval($settings['cycletype']) == 1 || empty($settings['cycletype'])}checked="checked"{/if}>无周期 
										</label>
										<label class="radio-inline">
											<input type="radio" name="set[cycletype]" value="2" {if intval($settings['cycletype']) == 2 }checked="checked"{/if}>自然月
										</label>
										<span class="help-block">不限制签到周期则统计时间为平台上线至今日，自然月统计周期则为本月，下月清空</span>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">虚拟签到人数</label>
									<div class="col-sm-9">
										<div class="input-group">
											<input type="number" min="0" name="set[signnum]" class="form-control" value="{$settings['signnum']}" />
											<span class="input-group-addon">人</span>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">普通奖励</label>
									<div class="col-sm-9">
										<div class="input-group form-group col-sm-6" style="margin: 0px;padding-left: 0;float: left;">
											<span class="input-group-addon" >日常奖励</span>
											<input type="number" step="0.01" min="0" name="set[daily]" class="form-control" value="{$settings['daily']}" />
											<span class="input-group-addon" >积分</span>
										</div>
										<div class="input-group form-group col-sm-6" style="margin: 0px;padding-right: 0;float: left;">
											<span class="input-group-addon" >首次奖励</span>
											<input type="number" step="0.01" min="0" name="set[first]" class="form-control valid" value="{$settings['first']}">
											<span class="input-group-addon" >积分</span>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">连续签到奖励</label>
									<div class="col-sm-9">
										<div id="datas" class="sms-template-1" style="display:block;">
											{if !empty($settings['totalreward'])}
											{loop $settings['totalreward'] $data}
											{php include wl_template('signsys/totalreward');}
											{/loop}
											{/if}
										</div>
										<div class="form-group sms-template-1" style="display:block;">
											<div class="col-sm-6" style="padding-left: 0;">
												<a class="btn btn-default btn-add-type btn1 min-width" href="javascript:;" onclick="addType();">
													<i class="fa fa-plus" title=""></i>增加一条累计奖励
												</a>
											</div>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">特殊奖励</label>
									<div class="col-sm-9">
										<div id="datas2" class="sms-template-1" style="display:block;">
											{if !empty($settings['specialreward'])}
											{loop $settings['specialreward'] $spe}
											{php include wl_template('signsys/specialreward');}
											{/loop}
											{/if}
										</div>
										<div class="form-group sms-template-1" style="display:block;">
											<div class="col-sm-6" style="padding-left: 0;">
												<a class="btn btn-default btn-add-type btn2 min-width" href="javascript:;" onclick="addType2();">
													<i class="fa fa-plus" title=""></i>增加一条特殊奖励
												</a>
											</div>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label"></label>
									<div class="col-sm-9">
										<a class="btn btn-success" href="{php echo web_url('wlsign/signset/update')}">清除签到数据</a>
										<span class="help-block">请在要完全重新开始签到活动时，清除用户签到数据</span>
									</div>
								</div>
							</div>
							<div class="tab-pane" id="tab_share">
								<div class="panel panel-default">
									<div class="panel-heading">分享规则</div>
									<div class="panel-body">
										<div class="alert alert-info">
											<b>适用模板变量：[昵称] [时间] [系统名称]</b>
										</div>
										<div class="form-group">
											<label class="col-sm-2 control-label">分享标题</label>
											<div class="col-xs-12 col-sm-8">
												<input type="text" name="set[share_title]" class="form-control" value="{$settings['share_title']}" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-2 control-label">分享图片</label>
											<div class="col-xs-12 col-sm-8">
												{php echo attachment_select('set[share_image]', $settings['share_image']);}
												<span class="help-block">图片建议为正方形</span>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-2 control-label">分享描述</label>
											<div class="col-xs-12 col-sm-8">
												<input type="text" name="set[share_desc]" class="form-control" value="{$settings['share_desc']}" />
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-2 control-label">规则详解</label>
											<div class="col-sm-9">
												{php echo tpl_diy_editor_create('set[detail]', $settings['detail']);}
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="tab-pane" id="tab_adv">
								<div class="panel panel-default">
									<div class="panel-heading">广告设置</div>
									<div class="panel-body">
										<div id="datas3" class="sms-template-1" style="display:block;">
											{if empty($settings['adv'])}
											{php include wl_template('signsys/imgandurl');}
											{else}
											{loop $settings['adv'] $key $data}
											{php include wl_template('signsys/imgandurl');}
											{/loop}
											{/if}
										</div>
										<div class="form-group sms-template-1" style="display:block;position: relative;left: 1rem;">
											<label class="col-sm-2 control-label"></label>
											<div class="col-sm-9">
												<a class="btn btn-default btn-add-type btn3" href="javascript:;" onclick="addType3();">
													<i class="fa fa-plus" title=""></i>增加图片链接
												</a>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-9">
						<input type="submit" name="submit" lay-submit value="提交" class="btn btn-primary min-width" />
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<script>
$(function () {
		window.optionchanged = false;
		$('#myTab a').click(function (e) {
			e.preventDefault();//阻止a链接的跳转行为
			$(this).tab('show');//显示当前选中的链接及关联的content
		})
	});
var kw = 1;
var kw2 = 1;
var kw3 = 1;
function addType() {
	    $(".btn1").button("loading");
	    $.ajax({
	        url: "{php echo web_url('wlsign/signset/totalreward')}&kw="+kw,
	        cache: false
	    }).done(function (html) {
	        $(".btn-add-type").button("reset");
	        $("#datas").append(html);
	    });
	    kw++;
	}
function addType2() {
	    $(".btn2").button("loading");
	    $.ajax({
	        url: "{php echo web_url('wlsign/signset/specialreward')}&kw="+kw2,
	        cache: false
	    }).done(function (html) {
	        $(".btn-add-type").button("reset");
	        $("#datas2").append(html);
	    });
	    kw2++;
	}
function addType3() {
	    $(".btn3").button("loading");
	    $.ajax({
	        url: "{php echo web_url('wlsign/signset/imgandurl')}&kw="+kw3,
	        cache: false
	    }).done(function (html) {
	        $(".btn-add-type").button("reset");
	        $("#datas3").append(html);
	    });
	    kw2++;
	}
</script>
{php include wl_template('common/footer');}

